{% extends base %}

{% block body %}
{% init file_type = "history" %}

<style>
    .history-detail-md {
        position: absolute;
        width: 100%;
        top: 0px;
        bottom: 0px;
    }
</style>

<div class="card">
    <h3 class="card-title btn-line-height">
        <a href="{{current_note.url}}" class="link2">{{current_note.name}}</a>
        <span>/</span>
        <span>{{T("History")}}</span>

        <div class="float-right">
            <button class="btn btn-default" onclick="javascript:history.back();">返回</button>
        </div>
    </h3>
</div>

<div class="card">

    <table class="table">
        <tr>
            <th>名称</th>
            <th>时间</th>
            <th>版本</th>
            <th>操作</th>
        </tr>

        {% for note in history_list %}
        <tr>
            <td>{{note.name}}</td>
            <td>{{note.mtime}}</td>
            <td>{{note.version}}</td>
            <td><button class="view-btn" data-version="{{note.version}}">查看</button></td>
        </tr>
        {% end %}
    </table>
</div>

<script type="text/javascript">
$(function () {

    $(".view-btn").click(function (e) {
        var note_id = getUrlParam("id");
        var version = $(this).attr("data-version");
        var width   = $(".root").width() - 40;
        $.get("/note/history_view", {id: note_id, version: version}, function (resp) {
            var content = $("<div>").append($("<textarea>").text(resp.data).addClass("history-detail-md")).html();
            xnote.showDialog("版本 - " + version, content, ["确定"]);
        }).fail(function (resp) {
            layer.alert("系统繁忙，请重试");
        });
    })

})
</script>

{% end %}

{% block aside %}
    {% include note/component/mod_aside.html %}
{% end %}
